/*********************************************************
/* mem.c						 *
/* Functions for memory manipulation			 *
/*********************************************************/

#include <mem.h>

/* Sets n bytes starting at the address defined by dest with the contents of src
   i.e. if dest == "Hello"
        and src == 'J'
  	and n == 1
  	The new contents of dest == "Jello"
*/
void *memset(void *s, int c, int n)
{
	unsigned char* p=s;

    	while(n--) {
        	*p++ = (unsigned char)c;
	}
    	return s;
}

/* Copy n bytes starting at the address defined by dest with the contents of src
   i.e if dest == "foo bar"
       and src == "poo"
       and n == 3
       The new contents of dest == "poo bar"
*/	
void *memcpy(void *dest, const void *src, int n)
{
	char *dp = dest;
    	const char *sp = src;
    	while (n--) {
        	*dp++ = *sp++;
	}
    	return dest;
}
